function Connection(role,socket) {
	var _this=this;
	//角色
	_this.role=role;
	//对方角色
	_this.to;
	//websocket
	_this.socket =socket;
	//peerconnection
	//_this.pc = new PeerConnection(config.iceServer);
	var iceServer = {
	        "iceServers": [{
	            "url": "stun:stun.l.google.com:19302"
	        }]
	    };
	  _this.pc = new PeerConnection(iceServer);
	var onicecandidate=function(event) {
		if (event.candidate !== null) {
			var ele;
			ele = JSON.stringify({
				"event" : "_ice_candidate",
				"owner" : _this.role,
				"to"	: _this.to,
				"data" : {
					"candidate" : event.candidate
				}
			});
			_this.socket.send(ele);
		} else {
		}
	};
	var onaddstream = function(event) {
		document.getElementById(_this.to + 'Video').src = URL
				.createObjectURL(event.stream);
	};
	//获得本机ice候选时，发送本机ICE候选到其他客户端
	_this.pc.onicecandidate = onicecandidate;
	//接收到另一方的steam时，将他放入录像
	_this.pc.onaddstream = onaddstream;
	
	var sendOfferFn = function(desc) {
		_this.pc.setLocalDescription(desc);
		_this.socket.send(JSON.stringify({
			"event" : "_offer",
			"owner" : _this.role,
			"to"	: _this.to,
			"data" : {
				"sdp" : desc
			}
		}));
	};
	_this.sendAnswerFn = function(desc) {
		_this.pc.setLocalDescription(desc);
		_this.socket.send(JSON.stringify({
			"event" : "_answer",
			"owner" : _this.role,
			"to"	: _this.to,
			"data" : {
				"sdp" : desc
			}
		}));
	};
	_this.start=function(){
		_this.pc.createOffer(sendOfferFn, function (error) {
        });
	}
}